home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / ab20 / unarced / graphics / anim / displayanim.c < prev    next >
C/C++ Source or Header  |  1995-03-17  |  3KB  |  111 lines

  1.  
  2. /* displayanim
  3.  *
  4.  *      Main program for animation file playing program
  5.  *         Derived from ShowANIM code as a working example of
  6.  *         ANIM playback.
  7.  *
  8.  *      Gary Bonham
  9.  *      SPARTA, Inc.
  10.  *      Laguna Hills, Ca
  11.  *
  12.  */
  13.  
  14.  
  15. #include "intuall.h"
  16. #include "graphics/display.h"
  17. #include "libraries/dos.h"
  18. #include "libraries/dosextens.h"
  19. #include "ilbm.h"
  20. #include "readpict.h"
  21. #include "stdio.h"
  22. #include "time.h"
  23. #include "putanim.h"
  24. #include "functions.h"
  25. #include "preloadanim.h"
  26.  
  27. extern int loopplay,continuousplay;
  28.  
  29. extern int EndFlag;
  30. int Ddx,Ddy;
  31. extern struct IFFfile *IFFfileList;
  32. extern LONG file;
  33. extern LONG OpenArg();
  34. char cc2[40],cc[40],line[81];
  35. struct Preferences *Prefs;
  36. int ScreenNTSC;
  37.  
  38. extern struct GfxBase *GfxBase;
  39.  
  40. /* ================================================= */
  41.  
  42. void main (argc,argv)
  43. int argc;
  44. char **argv;
  45. {
  46.    BYTE *ripcord;
  47.    char ch;
  48.    int i,ii,GoOn,delay,loops,loop;
  49.  
  50.    Prefs = 0;
  51.  
  52.    puts("\n*** SPARTA DisplayANIM ver. 1.00 ***\n");
  53.    puts("\nUse CTRL-C to abort once ANIM is playing\n");
  54.  
  55.    OpenLibs();                         /* open libraries */
  56.    Prefs = (struct Preferences *)AllocMem
  57.                  ((long)sizeof(struct Preferences),0L);
  58.    GetPrefs(Prefs,(long)sizeof(struct Preferences));
  59.  
  60.    if (GfxBase->DisplayFlags & PAL) ScreenNTSC = 0;
  61.    else ScreenNTSC = 1;
  62.  
  63.    Ddx = 0;
  64.    Ddy = 0;
  65.    if ((file = OpenArg(argc,argv)) == NULL)
  66.       GoodBye("Can't open ANIM file");
  67.    puts("Patience, Loading ANIM into memory...");
  68.    ripcord = AllocMem(16000L,(long)MEMF_CHIP); /* so ANIM doesn't use it all */
  69.       EndFlag = 0;
  70.       LoadAnim("ANIM");
  71.    FreeMem(ripcord,16000L);
  72.    GfxBase->system_bplcon0 |= INTERLACE;
  73.  
  74.             delay = 0;
  75.             loops = 1;
  76.             ii = 1;
  77.             if (continuousplay) {
  78.                if (EndFlag) {
  79.                   puts(" *** -c changed to -l ***\n");
  80.                   loopplay = continuousplay;
  81.                   continuousplay = 0;
  82.                }
  83.                else ii = continuousplay;
  84.             }
  85.             if (loopplay)       loops = loopplay;
  86.             DBOpenGraphics(2,IFFfileList->firstframe->bmhd->pageWidth
  87.                             ,IFFfileList->firstframe->bmhd->pageHeight
  88.                             ,IFFfileList->firstframe->bmhd->nPlanes);
  89.                for (loop=0;loop<loops;loop++) {
  90.                   i = ii + 1;
  91.                   while ((i = PlayAnim(IFFfileList,i,delay))) {}
  92.                }
  93.             DBCloseGraphics();
  94.       GfxBase->system_bplcon0 &= ~INTERLACE;
  95.    for (i=0;i<2;i++) DBCloseBuffer(i);
  96.    ClosePreLoadIFF();
  97.    GoodBye("done...");
  98. }
  99.  
  100. getch()
  101. {
  102.    char scr[80];
  103.    if (gets(scr)) {
  104.       if (scr[0] >= 'a' && scr[0] <= 'z')
  105.          scr[0] = scr[0] - 'a' + 'A';
  106.       return ((int)scr[0]);
  107.    }
  108.    return(' ');
  109. }
  110.  
  111.